package com.zhsm.fuxi.mvp.ui.activitys

import android.view.View
import com.hankkin.reading.base.BaseMvpActivity
import com.zhsm.fuxi.R
import com.zhsm.fuxi.bean.InvoiceDetailResp
import com.zhsm.fuxi.mvp.contract.InvoiceDetailContract
import com.zhsm.fuxi.mvp.presenter.InvoiceDetailPresenter
import com.zhsm.fuxi.utils.TimeUtils
import kotlinx.android.synthetic.main.activity_invoice_detaile.*
import kotlinx.android.synthetic.main.layout_head_bar.view.*
import org.jetbrains.anko.sdk25.coroutines.onClick

class InvoiceDetaileActivity : BaseMvpActivity<InvoiceDetailPresenter>(), InvoiceDetailContract.IView {
    var invoiceId = ""
    override fun getLayoutId(): Int {
       return R.layout.activity_invoice_detaile
    }
    override fun registerPresenter() = InvoiceDetailPresenter::class.java
    override fun initView() {
        setMiuiStatusBar()
        invoiceDetailHead.imgLift.onClick { finish() }
        invoiceDetailHead.tvTitle.text = "开票详情"
        invoiceId = intent.getStringExtra("invoiceId")
    }
    override fun initData() {
        getPresenter().getInvoiceDetail(invoiceId)
    }

    override fun getInvoiceDetailSucess(it: InvoiceDetailResp?) {
        it?.run {
            if (invoiceType == 2) {  //2企业
                invoiceDetailShLl.visibility = View.VISIBLE
                invoiceDetailSh.text = invoiceTaxNum
            } else invoiceDetailShLl.visibility = View.GONE
            invoiceDetailTt.text = invoiceTitle
            invoiceDetailDm.text = invoiceCode
            invoiceDetailHm.text = invoiceNumber
            invoiceDetailNum.text = invoiceAmount
            invoiceDetailTime.text = TimeUtils.getTime(updateTime!!, TimeUtils.DATE_CHAIN_DATA)
        }
    }

    override fun getInvoiceDetailtFail() {
    }
}
